﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
using FBEntities;
using XFControls.XFPanels;
using System.Xml.Linq;
using FBEntities.FBObjects;

namespace XDAFacebook
{
    public partial class Main : Form
    {
        private string settingsFileName = "\\XDAFacebookSettings.xml";
        public Main()
        {
            InitializeComponent();

            XFPanelHome panel = new XFPanelHome();

            xfPanelContainer.SetHeader(xfPanelHeader);
            xfPanelContainer.SetMainPanel(panel);
            xfPanelContainer.UpdateNotification = new FBNotifications();
            xfPanelContainer.UpdateNotification.StartUpdates();
            settingsFileName = LoginCustom.GetCurrent_Directory() + settingsFileName;
        }

        private void miExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void miLogOut_Click(object sender, EventArgs e)
        {
            if (File.Exists(settingsFileName))
            {
                var settings = XDocument.Load(settingsFileName);

                if (settings.Root.Descendants("auth_key").Any())
                    settings.Root.Element("auth_key").Value = "";

                settings.Save(settingsFileName);
            }

            LoginCustom cust = new LoginCustom();
            cust.Show();
            Close();
        }
    }
}